const mongoose = require('mongoose')
const { generateId } = require('../../utils/index')
const { dbHost } = require('../../conf/index')
mongoose.connect(`mongodb://${dbHost}/music_db`)

const Schema = mongoose.Schema

const vipSchema = new Schema({
  vipNo: {
    type: String,
    default() {
      return generateId('VIP')
    }
  },
  userNo: { type: String, required: [true, '用户编号为空'] },
  vipGrade: { type: Number, default: 1 }, // 当前等级
  nowExperience: { type: Number, default: 0 }, // 当前经验值
  fullExperience: { type: Number, default: 100 }, // 升下一级所需经验值
  vip: { type: Boolean, default: false }, // 是否是vip
  vipStartTime: { type: Date, default: new Date() },
  vipEndTime: { type: Date, default: null }
})

module.exports = mongoose.model('vip_grade', vipSchema)
